package com.atguigu.cloud.controller;

import com.atguigu.cloud.service.StorageService;
import com.atguigu.cloud.utils.ResultData;
import com.atguigu.cloud.utils.ReturnCodeEnum;
import io.seata.core.protocol.ResultCode;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: huahua
 * @Date: 2024/6/26 0026
 * @Time: 21:32
 * @Description:
 */
@RestController
@Slf4j
public class StorageController {
    @Resource
    private StorageService storageService;

    @PostMapping(value = "/storage/decrease")
    ResultData decrease(@RequestParam("productId") Long productId, @RequestParam("count") Integer count){
        boolean flag = storageService.decrease(productId,count);


        return flag ? ResultData.success(ResultData.success("ok")) : ResultData.fail("1001","没有库存");
    }
}
